package com.ailk.aee.pcc.action;

import com.ailk.aee.pcc.server.UserPloyStateServer;
import com.asiainfo.appserver.Action;
import com.asiainfo.appserver.Request;
import com.asiainfo.appserver.Response;
import com.asiainfo.appserver.annotations.Function;
import com.asiainfo.appserver.annotations.Parameter;
import com.asiainfo.appserver.annotations.Type;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 更新用户的策略编码
 *
 * @author pengzhang
 */
@Function(
        description = "更新用户同步信息", parameters = {
        @Parameter(name = "userId", type = Type.String, description = "用户ID", required = true),
        @Parameter(name = "ployCode", type = Type.String, description = "策略编码", required = true),
        @Parameter(name = "userState", type = Type.String, description = "用户状态", required = true),
        @Parameter(name = "updateTime", type = Type.String, description = "更新时间（yyyymmddhhmiss）", required = false)
})
@Component
public class UpdateUserPloyState implements Action {

    @Autowired
    private UserPloyStateServer ployServer;

    @Override
    public Response execute(Request request) throws Exception {
        String userId = request.getString("userId");
        String ployCode = request.getString("ployCode");
        String userState = request.getString("userState");
        String updatetime = request.getString("updateTime");

        ployServer.updatePloyUserState(userId, ployCode, userState, updatetime);
        return Response.success();
    }
}
